{% extends 'layout.html' %}
{% block content %}
    <div class="container">
        {% csrf_token %}
        <h2>项目 <span style="color: aquamarine">{{ project_obj.title }}-{{ project_obj.get_env_display }}</span>的任务列表</h2>
        <a href="{% url 'deploytask_add' pid=project_obj.pk %}" style="margin: 5px;" class="btn btn-light">添加项目</a>
        <table class="table ">
            <thead>
                <tr>
                    <th>项目id</th>
                    <th>项目标识</th>
                    <th>项目状态</th>
                    <th>项目发布</th>
{#                    <th>项目环境</th>#}
{#                    <th>项目关联的服务器</th>#}
{#                    <th>项目线上地址</th>#}
                    <th>操作</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for item in task_list %}
                    <tr>
                        <td>{{ item.pk }}</td>
                        <td>{{ item.uid }}</td>
                        <td>{{ item.get_status_display }}</td>
{#                        <td>{{ item.get_env_display }}</td>#}
{#                        <td>#}
{#                            {% for i in item.server.all %}#}
{#                                <span style="border:1px solid #ddd;padding: 5px;">{{ i }}</span>#}
{#                            {% endfor %}#}
{#                            </td>#}
{#                        <td>{{ item.path }}</td>#}
                        <td><a href="{% url 'deploytask_deploy' pk=item.pk %}">发布</a></td>
                        <td><a href="{% url 'deploytask_edit' pid=project_obj.pk pk=item.pk %}">编辑</a></td>
                        <td><a href="" onclick="removeRow(this,{{ item.pk }})">删除</a></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
{% block js %}
    <script>
        function removeRow(ths,id) {
            let reslut=confirm('是否确定要删除？');
            if(reslut){
                $.ajax({
                    url:'/project/delete/'+id+'/',
                    data:{
                        csrfmiddlewaretoken:"{{ csrf_token }}",
                    },
                    type:'post',
                    success:function (arg) {
                         $(ths).parent().parent().remove();
                    }
                })

            }

        }
    </script>
{% endblock %}